#ifndef BRAINSTORM_H
#define BRAINSTORM_H

#include <QDialog>
#include"communicate.h"
#include <QJsonDocument>
#include<QJsonObject>
#include<QJsonArray>
#include<QTimer>
#include<QTimerEvent>
#include<iostream>
#include   "cmd.h"
namespace Ui {
class BrainStorm;
}

class BrainStorm : public QDialog
{
    Q_OBJECT

public:
    explicit BrainStorm(communicate*com,QJsonObject &json,QWidget *parent = nullptr);
    ~BrainStorm();
protected:
    void singleGetQ();
    //单人设置问题显示
    void setSingleQ();
//设置对手得分
    void setEnemyScore();
    void setMyScore();
    //单人回答的结果
    void singleAnswerQ(int i);
    //本次回答的结果操作
    void rankAnswerQ(int i);
    //rank设置问题
    void setRankQ();
    //rank结束的结果
    void setRankResult(QJsonObject json);
private slots:
    //接受rank的服务端返回
    void Rank(QJsonObject json);
    //接受服务的的问题
    void receiveSingleQ(QJsonArray  json);

    void on_pushButton_4_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_clicked();
    \
    void singleTimerOut();

    void rankTimerOut();

    void on_pushButton_3_clicked();

    void on_singleSelectButton1_clicked();

    void on_singleSelectButton2_clicked();

    void on_singleSelectButton3_clicked();

    void on_singleSelectButton4_clicked();

    void on_rankButton_clicked();


    void on_rankpushButton_1_clicked();

    void on_rankpushButton_2_clicked();

    void on_rankpushButton_3_clicked();

    void on_rankpushButton_4_clicked();

    void on_rank_result_back_clicked();

private:
    Ui::BrainStorm *ui;
    communicate* com;
    QJsonArray singleQ;//当前问题集合
    int num;//当前题目下标
    QTimer singleTimer;//个人时钟
    int time;//每个问题的时间数
    int score;//得分数
    QJsonArray RankQ;
    QString enemyName;
    QString enemyRank;
    int enemyScore;
    int rankSec;//rank计时器
    int myScore;

    QString userName;
    QString userRank;
    int num2;//rank的当前问题下标
    int num3;//对手rank的当前问题下标
     QTimer rankTimer;//rank定时器

};

#endif // BRAINSTORM_H
